package org.example.news_check.ServiceImpl;

import com.github.pagehelper.PageInfo;
import org.example.news_check.Mapper.CommentMapper;
import org.example.news_check.Pojo.Comment;
import org.example.news_check.Service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentMapper commentMapper;

    @Override
    public Comment add(Comment comment) {
       commentMapper.add(comment);
       return comment;
    }

    @Override
    public List<Comment> findByNewsId(Integer newsId) {
        return commentMapper.findByNewsId(newsId);
    }


    @Override
    public void delete(Integer id) {
        commentMapper.delete(id);
    }

    @Override
    public List<Comment> findAll(Integer newsId) {//查询某条新闻的所有评论
        return commentMapper.findAll(newsId);
    }


}